package com.xiaoshu.controller;

import com.xiaoshu.model.ResultCode;
import com.xiaoshu.model.ResultVo;
import com.xiaoshu.service.dubbo.HelloConsumerImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 功能说明：
 *
 * @ com.xiaoshu.service.controller
 * <p>
 * Original @Author: deane.jia-贾亮亮,@2020/9/25@9:10
 * <p>
 * Copyright (C)2012-@2020 深圳小树盛凯科技 All rights reserved.
 */
@RestController
@RequestMapping(value = "/dubbo")
@Slf4j
@Api(value = "Dubbo service")
public class DubboController {

    @Autowired
    private HelloConsumerImpl helloConsumer;

    @RequestMapping(value = "/name", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "Dubbo Consumer接口")
    public ResultVo<String> helloDubboName(@ApiParam(value = "name") @RequestParam(value = "name") String name) {
        log.info("start get name from dubbo ,name is :{}", name);
        return new ResultVo<>(ResultCode.SUCCESS, helloConsumer.helloService.getName(name));
    }
}
